<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<html>
<head>
    <title>账号管理</title>
    <!--引入elementui得样式-->
    <link type="text/css" rel="stylesheet" href="/css/index.css"/>
    <!--引入vue得依赖必须再elementui之前引入vue-->
    <script type="text/javascript" src="/js/vue.js"></script>
    <script type="text/javascript" src="/js/index.js"></script>
    <script type="text/javascript" src="/js/axios.min.js"></script>
    <script type="text/javascript" src="/js/qs.min.js"></script>
</head>

<div id="login">
    <div id="loginBox">
        <el-form :model="loginForm" status-icon :rules="loginRules" ref="ruleForm"  label-width="80px" class="demo-ruleForm" id="loginForm">
            <el-form-item label="原账号:">
                <el-input type="text" v-model="loginForm.account" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="原密码:">
                <el-input type="text" v-model="loginForm.password" autocomplete="off"></el-input>
            </el-form-item>
            <el-form-item label="确认密码:">
                <el-input type="password" v-model="loginForm.pass" autocomplete="off"></el-input>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="login()">确认修改</el-button>
            </el-form-item>
        </el-form>
    </div>
</div>
</body>
<script>
    var app=new Vue({
        el:"#login",
        data:{
            loginForm:{},
            loginRules:{
                password1:[
                    { required: true, message: '请输入原密码', trigger: 'blur' },
                ],
                password:[
                    { required: true, message: '确认密码', trigger: 'blur' },
                ]
            }

        },
        methods:{
            login(){
                this.$refs.ruleForm.validate((valid) => {
                    if(valid){
                        axios.post("/admin/updatepassword",this.loginForm).then(resp=>{
                            if(resp.data.code===200){
                                console.log(this.loginForm);
                                this.$message.success("修改成功");
                                this.loginForm='';

                            }else{
                                this.$message.error("修改失败");
                            }
                        })
                    }
                })
            },
        }
    })
</script>

<style>
    #loginBox{
        width: 450px;
        height: 300px;
        margin: 200px auto;
    }
    #loginForm{
        margin: 20px auto;
    }
</style>
</html>